package com.shrct.businessprocess.customerservice.impl;

import com.shrct.businessprocess.customerservice.RCRoutineServiceItem;
import com.shrct.businessprocess.customerservice.RCRoutineServiceItemCriteria;
import com.shrct.businessprocess.customerservice.RCRoutineServiceItemStatus;
import com.shrct.businessprocess.organization.RCEnterprise;
import edu.fudan.mylang.pf.query.HQLBasedPagedQueryCriteria;
import java.util.Date;
import org.hibernate.Query;

public class RCRoutineServiceItemCriteriaImpl extends HQLBasedPagedQueryCriteria<RCRoutineServiceItem> implements RCRoutineServiceItemCriteria {
  private RCRoutineServiceItemStatus status;
  
  public RCRoutineServiceItemStatus getStatus() {
    return this.status;
  }
  
  public RCRoutineServiceItemCriteria setStatus(final RCRoutineServiceItemStatus status) {
    this.status = status;
    return this;			
    
  }
  
  private Date planDateFrom;
  
  public Date getPlanDateFrom() {
    return this.planDateFrom;
  }
  
  public RCRoutineServiceItemCriteria setPlanDateFrom(final Date planDateFrom) {
    this.planDateFrom = planDateFrom;
    return this;			
    
  }
  
  private Date planDateTo;
  
  public Date getPlanDateTo() {
    return this.planDateTo;
  }
  
  public RCRoutineServiceItemCriteria setPlanDateTo(final Date planDateTo) {
    this.planDateTo = planDateTo;
    return this;			
    
  }
  
  private String location;
  
  public String getLocation() {
    return this.location;
  }
  
  public RCRoutineServiceItemCriteria setLocation(final String location) {
    this.location = location;
    return this;			
    
  }
  
  private RCEnterprise customer;
  
  public RCEnterprise getCustomer() {
    return this.customer;
  }
  
  public RCRoutineServiceItemCriteria setCustomer(final RCEnterprise customer) {
    this.customer = customer;
    return this;			
    
  }
  
  private String contractId;
  
  public String getContractId() {
    return this.contractId;
  }
  
  public RCRoutineServiceItemCriteria setContractId(final String contractId) {
    this.contractId = contractId;
    return this;			
    
  }
  
  private String projectId;
  
  public String getProjectId() {
    return this.projectId;
  }
  
  public RCRoutineServiceItemCriteria setProjectId(final String projectId) {
    this.projectId = projectId;
    return this;			
    
  }
  
  private String groupName;
  
  public String getGroupName() {
    return this.groupName;
  }
  
  public RCRoutineServiceItemCriteria setGroupName(final String groupName) {
    this.groupName = groupName;
    return this;			
    
  }
  
  protected String buildHQLFrom() {
    return " from com.shrct.businessprocess.customerservice.impl.RCRoutineServiceItemImpl this ";
  }
  
  protected String buildHQLBody() {
    String hql = "where 1 = 1 ";
    if( !edu.fudan.mylang.pf.query.QueryUtil.isNull(getStatus()) ){
    	hql += " and ((this.status) = (:status))" ;
    }
    if( !edu.fudan.mylang.pf.query.QueryUtil.isNull(getPlanDateFrom()) ){
    	hql += " and ((this.planDate) >= (:planDateFrom))" ;
    }
    if( !edu.fudan.mylang.pf.query.QueryUtil.isNull(getPlanDateTo()) ){
    	hql += " and ((this.planDate) <= (:planDateTo))" ;
    }
    if( !edu.fudan.mylang.pf.query.QueryUtil.isNull(getLocation()) ){
    	hql += " and (this.rountineService.installLocation  LIKE :location)" ;
    }
    if( !edu.fudan.mylang.pf.query.QueryUtil.isNull(getCustomer()) ){
    	hql += " and ((this.rountineService.projectInfo.customer) = (:customer))" ;
    }
    if( !edu.fudan.mylang.pf.query.QueryUtil.isNull(getContractId()) ){
    	hql += " and (this.rountineService.projectInfo.contractId  LIKE :contractId)" ;
    }
    if( !edu.fudan.mylang.pf.query.QueryUtil.isNull(getProjectId()) ){
    	hql += " and (this.rountineService.projectInfo.projectId  LIKE :projectId)" ;
    }
    if( !edu.fudan.mylang.pf.query.QueryUtil.isNull(getGroupName()) ){
    	hql += " and (this.rountineService.groupName  LIKE :groupName)" ;
    }
    return hql;
    
  }
  
  public void initOrderBys() {
    addOrder("this.planDate",edu.fudan.mylang.pf.query.OrderItem.ASC);
  }
  
  protected void fillParameter(final Query query) {
    if( !edu.fudan.mylang.pf.query.QueryUtil.isNull(getStatus())){
    	query.setParameter("status",getStatus()) ;
    }			
    if( !edu.fudan.mylang.pf.query.QueryUtil.isNull(getPlanDateFrom())){
    	query.setParameter("planDateFrom",getPlanDateFrom()) ;
    }			
    if( !edu.fudan.mylang.pf.query.QueryUtil.isNull(getPlanDateTo())){
    	query.setParameter("planDateTo",getPlanDateTo()) ;
    }			
    if( !edu.fudan.mylang.pf.query.QueryUtil.isNull(getLocation())){
    	query.setParameter("location",getLocation()) ;
    }			
    if( !edu.fudan.mylang.pf.query.QueryUtil.isNull(getCustomer())){
    	query.setParameter("customer",getCustomer()) ;
    }			
    if( !edu.fudan.mylang.pf.query.QueryUtil.isNull(getContractId())){
    	query.setParameter("contractId",getContractId()) ;
    }			
    if( !edu.fudan.mylang.pf.query.QueryUtil.isNull(getProjectId())){
    	query.setParameter("projectId",getProjectId()) ;
    }			
    if( !edu.fudan.mylang.pf.query.QueryUtil.isNull(getGroupName())){
    	query.setParameter("groupName",getGroupName()) ;
    }			
    
  }
  
  protected Boolean isDistinct() {
    return false;
  }
  
  public RCRoutineServiceItemCriteriaImpl() {
    initOrderBys();
  }
}
